package com.nine.gxh.controller;

import com.ruoyi.common.constant.MyRabbitDelayConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;

/**
 * @author: duonine
 * @date: 2023/7/7
 */
@RestController
@RequestMapping("/delay")
@Slf4j
public class TestDelayLetterController {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/test10")
    public AjaxResult testDelayLetter10(){
        String msg = "测试延时10s数据";
        log.info(msg);
        rabbitTemplate.convertAndSend(MyRabbitDelayConstants.DELAY_EXCHANGE_NAME, MyRabbitDelayConstants.DELAY_ROUTE_NAME_1, msg);
        return AjaxResult.success();
    }

    @GetMapping("/test30")
    public AjaxResult testDelayLetter30(){
        String msg = "测试延时30s数据";
        log.info(msg);
        rabbitTemplate.convertAndSend(MyRabbitDelayConstants.DELAY_EXCHANGE_NAME, MyRabbitDelayConstants.DELAY_ROUTE_NAME_2, msg);
        return AjaxResult.success();
    }

}
